﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;

/// <summary>
///TemplateEditShow 的摘要说明
/// </summary>
public class TemplateEditShow:BaseEditShowField
{
	public TemplateEditShow()
	{
		//
		//TODO: 在此处添加构造函数逻辑
		//
	}

    public override IEnumerable<Control> GetThisTypeControl(ConfigColumns cCol, string value, bool isEdit)
    {
        Page page = HttpContext.Current.Handler as Page;
        if (page != null)
        {
            Control ctrl = page.LoadControl(cCol.EditShowTemplatePath);
            ctrl.ID = cCol.ColumnName + "_EditShow";

            if (ctrl is IEditShowTemplate)
            {
                ctrl.Load += new EventHandler(delegate(object sender, EventArgs e)
                    {
                        ((IEditShowTemplate)ctrl).SetField(cCol,value,isEdit);
                    });
            }            

            yield return ctrl;
        }
        else
        {
            foreach (Control c in new TextEditShow().GetThisTypeControl(cCol, value, isEdit))
            {
                yield return c;
            }
        }
    }
}
